public class SetUp {

    public static void main(String[] args) {
        // 建树
        /*
                1
               / \
              2   3
             /   / \
            4   6   7
             \
              5
         */
        TreeNode root =
                new TreeNode(1,
                        new TreeNode(2,
                                new TreeNode(4,null,
                                        new TreeNode(5,null,null)),null),
                        new TreeNode(3,
                                new TreeNode(6,null,null),
                                new TreeNode(7,null,null)));

        System.out.println("preOrderTraverse Use recursion:");
        TreeNode.preOrderTraverse(root);
        System.out.println();
        System.out.println("preOrderTraverse Use iterator:");
        root.iterator().forEachRemaining(node -> System.out.print(node.getValue() + " "));
    }
}
